<?php
$appid = 'wx9ecd6f55cb302ad8';
$appsecret = '58d32045705fd1ec2796f771119930a5';
$code=trim($_GET['code']);

$data=file_get_contents("https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$appsecret}&js_code={$code}&grant_type=authorization_code");

//$json=json_decode($data,true);
//{"session_key":"\/HUFEtfj+qHcyKPz3XtfNA==","openid":"o_o251SpI0f3wsSiHZXmEL-xTzOY"}

//openid 入库
echo $data; 